package com.wcy.bysj.service.impl;

import com.wcy.bysj.common.Page;
import com.wcy.bysj.common.Result;
import com.wcy.bysj.dao.FoodMapper;
import com.wcy.bysj.entity.Food;
import com.wcy.bysj.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {

    @Autowired
    private FoodMapper foodMapper;

    @Override
    public Result addFood(Food food) {
        int i = foodMapper.insert(food);
        return Result.success(i);
    }

    @Override
    public Result selectAllFood(Food food) {
        Page page = new Page();
        List<Food> list = foodMapper.selectAll(food);
        return Result.success(list);
    }

    @Override
    public Result updateFood(Food food) {
        int i = foodMapper.updateByPrimaryKey(food);
        return Result.success(i);
    }

    @Override
    public Result deleteFood(Food food) {
        int j = foodMapper.deleteByPrimaryKey(food.getId());
        return Result.success(j);
    }
}
